package com.yunze.system.service.impl.yunze.install;

import com.yunze.common.mapper.mysql.install.YzInstallLinkmanMapper;
import com.yunze.common.utils.yunze.PageUtil;
import com.yunze.system.service.yunze.install.YzInstallLinkmanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class YzInstallLinkmanServiceImpl implements YzInstallLinkmanService {

    @Resource
    private YzInstallLinkmanMapper yzInstallLinkmanMapper;

    @Override
    public Map<String, Object> ListMap(Map map) {
        Map<String, Object> omp=new HashMap<String, Object>();
        Integer currenPage=map.get("pageNum")!=null?Integer.parseInt(map.get("pageNum").toString()):0;
        Integer pageSize=map.get("pageSize")!=null?Integer.parseInt(map.get("pageSize").toString()):10;
        Integer rowCount = yzInstallLinkmanMapper.selMapCount(map);
        rowCount=rowCount!=null?rowCount:0;
        PageUtil pu=new PageUtil(rowCount,currenPage , pageSize);//初始化分页工具类
        //数据打包
        map.put("StarRow", pu.getStarRow());
        map.put("PageSize", pu.getPageSize());
        omp.put("Pu", pu);
        omp.put("Data", yzInstallLinkmanMapper.selMap(map));
        return omp;
    }

    @Override
    public boolean add(Map map) {
        return yzInstallLinkmanMapper.add(map);
    }

    @Override
    public boolean phone(Map map) {

        String Str = map.get("phone").toString();
        boolean bool = false;
        List<Map<String, Object>> list = yzInstallLinkmanMapper.phone(map);
        for (Map<String, Object> Rmap : list) {
            String phone = Rmap.get("phone").toString();
            if (phone.equals(Str)) {
                bool = true;
                break;
            } else {
                bool = false;
            }
        }
        return bool;
    }

    @Override
    public boolean delId(Map map) {
        return yzInstallLinkmanMapper.delId(map)>0;
    }

    @Override
    public boolean updForm(Map map) {
        return yzInstallLinkmanMapper.updForm(map)>0;
    }
}
